//
//  ShapeFactory.m
//  享元模式
//
//  Created by flannery on 2018/12/18.
//  Copyright © 2018年 flannery. All rights reserved.
//

#import "ShapeFactory.h"

@implementation ShapeFactory

+ (id<Shape>)getCircle:(NSString *)color{
    static NSMutableDictionary *dict;
    if(dict == nil) {
        dict = [[NSMutableDictionary alloc]init];
    }
    Circle *circle = [dict objectForKey:color];
    if(circle == nil) {
        circle = [[Circle alloc]initWithColor:color];
        [dict setObject:circle forKey:color];
        NSLog(@"Creating circle of color : %@" , color);
    }
    return circle;
}

@end
